package modules::cuffcompare;

sub new {
  my ($class,$config,$tophat_dir)    = @_;

  my $self = {
               _path         => $config->{'PATH'      },
               _job_name     => $config->{'JOB_NAME'  },
               _genome       => $config->{'GENOME'    },
               _gtf_file     => $config->{'GTF_FILE'  },
             };
  bless $self,$class;
  return $self;
}

sub prepare {
  my ($self)                  = @_;
  my $job_name                = $self->{'_job_name'};
  my $path                    = $self->{'_path'};
  my $cuffcompare_out         = "$path/results/$job_name/Cuffcompare";
  $self->{'_cuffcompare_out'} = $cuffcompare_out;
  
  print "Creating '$cuffcompare_out'...\n";
  mkdir  $cuffcompare_out, 777; chmod(0777, $cuffcompare_out);
  
  return;
}

sub run {
  my ($self)            = @_;
  my $cuffcompare_out   = $self->{'_cuffcompare_out' };
  my $genome            = $self->{'_genome'          };
  my $gtf_file          = $self->{'_gtf_file'        };
 
  $cmd = qq(bsub -Is -n 4 -R "span[ptile=4] rusage[mem=5000]" )
       . qq(" cufflinks-1.3.0 cuffcompare -r $gtf_file -o $cuffcompare_out )
       . qq( -s $genome.fa -p 8 )
       . qq( $gtf_file $gtf_file ");
   
  print "\n\nRUNNING COMMAND:\n$cmd\n\n";
  system($cmd);
  return;

}
1; 


